﻿// <auto-generated />
using System;
using IS2.Database.ConfigurationData;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace IS2.Database.ConfigurationData.Migrations
{
    [DbContext(typeof(ConfigurationDataContext))]
    [Migration("20230524094301_Initial")]
    partial class Initial
    {
        /// <inheritdoc />
        protected override void BuildTargetModel(ModelBuilder modelBuilder)
        {
#pragma warning disable 612, 618
            modelBuilder
                .HasAnnotation("ProductVersion", "7.0.5")
                .HasAnnotation("Relational:MaxIdentifierLength", 63);

            NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

            modelBuilder.Entity("IS2.Database.ConfigurationData.Model.Branch", b =>
                {
                    b.Property<Guid>("BranchId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<bool>("IsDeleted")
                        .HasColumnType("boolean");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("text");

                    b.HasKey("BranchId");

                    b.ToTable("Branches", (string)null);
                });

            modelBuilder.Entity("IS2.Database.ConfigurationData.Model.Setting", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("DateInsert")
                        .HasColumnType("timestamp with time zone");

                    b.Property<bool>("IsDeleted")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("boolean")
                        .HasDefaultValue(false);

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<Guid>("SettingId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("VersionId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("SettingId");

                    b.HasIndex("VersionId", "DateInsert", "IsDeleted");

                    b.ToTable("Settings", (string)null);
                });

            modelBuilder.Entity("IS2.Database.ConfigurationData.Model.UserSetting", b =>
                {
                    b.Property<Guid>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<DateTime>("DateInsert")
                        .HasColumnType("timestamp with time zone");

                    b.Property<bool>("IsDeleted")
                        .HasColumnType("boolean");

                    b.Property<Guid>("SettingId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("UserId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("UserSettingId")
                        .HasColumnType("uuid");

                    b.Property<string>("Value")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<Guid>("VersionId")
                        .HasColumnType("uuid");

                    b.HasKey("Id");

                    b.HasIndex("UserSettingId");

                    b.HasIndex("VersionId", "DateInsert", "IsDeleted");

                    b.ToTable("UserSettings", (string)null);
                });

            modelBuilder.Entity("IS2.Database.ConfigurationData.Model.Version", b =>
                {
                    b.Property<Guid>("VersionId")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("uuid");

                    b.Property<Guid>("BranchId")
                        .HasColumnType("uuid");

                    b.Property<string>("Comment")
                        .HasColumnType("text");

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("text");

                    b.Property<Guid?>("PreviousVersionId")
                        .HasColumnType("uuid");

                    b.Property<Guid>("UserId")
                        .HasColumnType("uuid");

                    b.Property<DateTime>("VersionDate")
                        .HasColumnType("timestamp with time zone");

                    b.Property<int?>("VersionType")
                        .HasColumnType("integer");

                    b.HasKey("VersionId");

                    b.HasIndex("BranchId");

                    b.ToTable("Versions", (string)null);
                });

            modelBuilder.Entity("IS2.Database.ConfigurationData.Model.VersionType", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasColumnType("integer");

                    NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasColumnType("text");

                    b.HasKey("Id");

                    b.ToTable("VersionTypes", (string)null);

                    b.HasData(
                        new
                        {
                            Id = 1,
                            Name = "Черновик"
                        },
                        new
                        {
                            Id = 2,
                            Name = "Подтверждена"
                        });
                });

            modelBuilder.Entity("IS2.Database.ConfigurationData.Model.Version", b =>
                {
                    b.HasOne("IS2.Database.ConfigurationData.Model.Branch", "Branch")
                        .WithMany("Versions")
                        .HasForeignKey("BranchId")
                        .OnDelete(DeleteBehavior.Cascade)
                        .IsRequired();

                    b.Navigation("Branch");
                });

            modelBuilder.Entity("IS2.Database.ConfigurationData.Model.Branch", b =>
                {
                    b.Navigation("Versions");
                });
#pragma warning restore 612, 618
        }
    }
}
